package cn.zhaolinbo.controller;

import cn.zhaolinbo.domain.User;
import cn.zhaolinbo.service.SpringBootService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by zhaolinbo on 2017/10/31.
 */
@Controller
public class SpringBootController {

    //注入service
    @Autowired
    private SpringBootService springBootService;

    @RequestMapping(value = "/springboot01",method = RequestMethod.GET)
    @ResponseBody
    public String test01() {
        System.out.println("___");
        return "这是springboot的测试";
    }

    @RequestMapping(value = "/springboot02",method = RequestMethod.GET)
    @ResponseBody
    public String test02(String name,String address) {
        System.out.println("___save");
        User user = new User();
        user.setName(name);
        user.setAddress(address);
        springBootService.save1(user);
        return "这是springboot的保存";
    }


    @RequestMapping(value = "/springboot03",method = RequestMethod.GET)
    @ResponseBody
    public String test03(String name,String address) {
        System.out.println("___mybatils");
        User user = new User();
        user.setName(name);
        user.setAddress(address);
        springBootService.save2(user);
        return "这是springboot  基于mybatis的保存";
    }
}
